#ifndef SIP_WTSXSIPSERVICEITF_HPP__
#define SIP_WTSXSIPSERVICEITF_HPP__

#include "WTSXSipService/SipSXServiceConfigure.hpp"
#include "WTSXSipService/SipWTSXTypes.hpp"

namespace wtsxsip{

class ISipDlgSessionBaseHandle;
class ISipTranSessionHandle;
class ISipSXServiceListener;


class WTSX_SIPSRV_PUBLIC ISipTranSession
{
public:
    typedef enum {
        Initial,
        Provisional,
        Completed,
        Failed
    } ETranSessionState;

public:

    virtual uint32_t getHandle() = 0;

    virtual bool send() = 0;

    virtual bool send(const SMsgBodyBase& body) = 0;

    virtual bool cancel() = 0;

    virtual bool reply(_in const SHeaders& headers, _in bool canceled=false) = 0;

    virtual bool reply(_in const SHeaders& headers, _in const SMsgBodyBase& body, _in bool canceled=false) = 0;

    virtual bool registerHandle(ISipTranSessionHandle* h) = 0;

    virtual bool unregisterHandle(ISipTranSessionHandle* h) = 0;
};


class WTSX_SIPSRV_PUBLIC ISipDlgSessionBase
{
public:

    typedef enum {
        Initial,
        CanEstablish,
        Established,
        Terminating
    } EDlgSessionState;

    typedef enum {
        Invite,
        NonInvite
    } EDlgType;

public:

    virtual uint32_t getHandle() = 0;

    virtual EDlgSessionState getState() = 0;

    virtual bool cancel() = 0;

    virtual bool send(_inout SHeaders& headers, _in const SMsgBodyBase& body, _out uint32_t& id) = 0;

    virtual bool stop() = 0;

    virtual bool registerHandle(ISipDlgSessionBaseHandle* h) = 0;

    virtual bool unregisterHandle(ISipDlgSessionBaseHandle* h) = 0;
};


class WTSX_SIPSRV_PUBLIC ISipSXService
{
public:

    virtual bool init(const wtsip::SUri& localInfo, const ETransport transport) = 0;

    virtual bool start() = 0;

    virtual bool stop() = 0;

    virtual bool registerServiceListener(ISipSXServiceListener* listener) = 0;

    virtual bool unregisterServiceListener() = 0;

    virtual const wtsip::SUri& getLocalInfo() = 0;

    virtual ISipTranSession* createTranSession(const wtsip::SUri& tar, const wtsip::SUri& local, 
        const wtsip::SUri& remote, const wtsip::EMethodTypes mth) = 0;

    virtual ISipDlgSessionBase* createDlgSession(const wtsip::SUri& tar, const wtsip::SUri& local, 
        const wtsip::SUri& remote, const ISipDlgSessionBase::EDlgType type) = 0;
};


class WTSX_SIPSRV_PUBLIC ISipDlgSessionBaseHandle
{
public:

    virtual bool onRequest(ISipDlgSessionBase& dlg, const SHeaders& headers, 
        const SMsgBodyBase& body, ISipTranSession& srvTran) = 0;

    virtual bool onResponse(ISipDlgSessionBase& dlg, const SHeaders& headers,
        const SMsgBodyBase& body, ISipTranSession& clnTran) = 0;

    virtual bool onState(ISipDlgSessionBase& dlg, const ISipDlgSessionBase::EDlgSessionState newState) = 0;

    virtual bool onDestroy(ISipDlgSessionBase& dlg, ISipTranSession& tran) = 0;

    virtual bool onDestroy(ISipDlgSessionBase& dlg) = 0;

};


class WTSX_SIPSRV_PUBLIC ISipTranSessionHandle
{
public:

    virtual bool onRequest(ISipTranSession& tran, const SHeaders& headers, const SMsgBodyBase& body) = 0;

    virtual bool onResponse(ISipTranSession& tran, const SHeaders& headers, const SMsgBodyBase& body) = 0;

    virtual bool onState(ISipTranSession& tran, const ISipTranSession::ETranSessionState newState) = 0;

    virtual bool onDestroy(ISipTranSession& tran) = 0;
};


class WTSX_SIPSRV_PUBLIC ISipSXServiceListener
{
public:

    virtual bool onRequest(ISipDlgSessionBase& dSession, ISipTranSession& tSession, 
        const SHeaders& headers, const SMsgBodyBase& body) = 0;

    virtual bool onRequest(ISipTranSession& tSession, const SHeaders& headers, 
        const SMsgBodyBase& body) = 0;

    virtual bool onDestroy() = 0;

};


}//namespace

#endif


